<?php 
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admenvfilesupp.php,v $ 
 * $Date: 2005/08/29 14:54:35 $ 
 * $Revision: 1.2 $ 
 * 
 * ********* CVS HEADER ********* 
 */
if (!isset($argid)) {
	rportalerreur("Aucun environnement en param&egrave;tre !","?op=admenvliste");
}
if (!isset($file) || !isset($action)) {
	header("Location: ?op=admenvfilelist&argid=".$argid);
	exit;
}
$L_confirmer="oui";
$L_annuler="non";
$L_modules = get_path("module");
$L_base_env = get_env_path();

$query="SELECT `nom` FROM environnement WHERE id='$argid'";
$result=rportalrequete($query) or rportalerreur($query,"?op=admenvliste");	
if(!$L_environnement=rportalligne($result)) {
	rportalerreur("L'environnement [id=$argid] n'existe pas","?op=admenvliste");
}

if(!(strpos($file,'..')===false)) {
	/* La presence de '..' est interdite */
	header("Location: ?op=admenvfilelist&argid=".$argid);
	exit;
}

$L_pos = strrpos($file,'/');
if ($L_pos === false) {
	$L_lien ="";
} else {
	$L_lien ="&file=";
	$L_lien.=substr($file,0,$L_pos+1);
} 

if ($L_pos == strlen($file)-1) {
	/* there is a "/" at the end */
	header("Location: ?op=admenvfilelist&argid=".$argid);
	exit;
}


if (isset($$L_annuler)) {
	header("Location: ?op=admenvfilelist&argid=".$argid.$L_lien );
	exit;
} else if (isset($$L_confirmer)) {
	header("Location: ?op=admenvfilelist&argid=".$argid."&file=".$file."&action=".$action );
	exit;
}

require_once($L_modules . "TPLN/TPLN.php");

$TPLN = new TPLN; 
$TPLN->Open($op_basepath.get_path("tpl")."admenvfilesupp.html"); 
$TPLN->IncludeFile("header",$L_base_env.$session['environnement']."/header.php");

$TPLN->Parse("argid",$argid);
$TPLN->Parse("environnement",$L_environnement['nom']);
$TPLN->Parse("lien",$L_lien);
$TPLN->Parse("fichier",$file);
$TPLN->Parse("supprimer",$action);
$TPLN->Parse("confirmer",$L_confirmer);
$TPLN->Parse("annuler",$L_annuler);

$TPLN->IncludeFile("footer",$L_base_env.$session['environnement']."/footer.php");
$TPLN->Write(); 
?> 